<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
		window.onload = function(){
				var oDiv = document.getElementById('div1');

				function fnTime(){
				var sNow = new Date();

				var sFuture = new Date(2019,10,10,24,0,0);

				var sLeft = parseInt((sFuture - sNow)/1000);

				var iDays = parseInt(sLeft/86400);

				var iHours = parseInt(sLeft%86400/3600);

				var iMinutes = parseInt(((sLeft%86400)%3600)/60);
				
				var iSeconds = parseInt(sLeft%60);

				var sTr = '距离11月11日还剩:' + fnTodouble(iDays) + '天' + fnTodouble(iHours) + '时'+ fnTodouble(iMinutes) + '分' + fnTodouble(iSeconds)  + '秒' 

				oDiv.innerHTML = sTr;}

				fnTime();
				setInterval(fnTime,1000);

				function fnTodouble(n){
					if(n<10)
						return '0' + n;
					else 
						return n;
			}
		}
	</script>

	<style type="text/css">
		.box{
			color:purple;
			font-size:30px;
			text-align:center;
			margin:50px auto 0;
		}
	</style>
</head>
<body>
	<div class="box" id="div1"></div>
</body>
</html>